package com.isoftstone.merchant.service.mproject.impl;

import com.isoftstone.common.Page;
import com.isoftstone.merchant.dao.mproject.MProjectMapper;
import com.isoftstone.merchant.entity.mproject.MProject;
import com.isoftstone.merchant.service.mproject.MProjectService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * Created by as on 2017/12/12.
 */
@Service
public class MProjectServiceImpl implements MProjectService{
    @Autowired
    MProjectMapper mProjectMapper;

    @Override
    public List<MProject> findprojectlistPage(Page page) throws Exception {
        return mProjectMapper.selectprojectlistPage(page);
    }
    @Override
    public List<MProject> checkName(Map<String, Object> map) throws Exception {
        return mProjectMapper.checkName(map);
    }
    @Override
    @Transactional
    public void saveMProjectType(MProject mProject) throws Exception {
        mProjectMapper.insertSelective(mProject);
    }
    @Override
    @Transactional
    public void updateMProjectType(MProject mProject) throws Exception {
        mProjectMapper.updateByPrimaryKeySelective(mProject);
    }
    @Override
    public Integer getCountFromMProject(Map<String, Object> map) throws Exception {
        return mProjectMapper.getCountFromMProject(map);
    }
    @Override
    @Transactional
    public void deleteMProjectType(long l) throws Exception {
        mProjectMapper.deleteByPrimaryKey(l);/////
    }

    @Override
    public  List<MProject> findProjectNameList(Long projectTypeId){
        return mProjectMapper.selectProject(projectTypeId);
    }

    @Override
    //根据项目类型查询下面的项目projectTypeId,cropId
    public List<MProject> findProjectListByType(Map<String, Object>map) {
        return mProjectMapper.selectProjectByType(map);
    }

    @Override
    public List<MProject> getProjectByCorpId(@Param("corpId") String corpId) throws Exception {
        return mProjectMapper.getProjectByCorpId(corpId);
    }

    @Override
    public List<MProject> getMemberShipProject(String corpId,String openAccount) throws Exception {
        return mProjectMapper.getMemberShipProject(corpId,openAccount);
    }

    @Override
    public List<MProject> getProjectNameByCropId(String corpId) throws Exception {
        return mProjectMapper.getProjectNameByCropId(corpId);
    }

    @Override
    public MProject getMProjectByProjectId(Long projectId) throws Exception {
        return mProjectMapper.selectByPrimaryKey(projectId);
    }

}
